﻿using System;
using System.Collections.Generic;
using Sandy.Queries;

namespace Sandy.Selectors
{
    // Path: client.SuperFamily("name")["key"]["superCol"]
    public class SubColumnGetSelector
    {
        private readonly SandyClient _client;
        private readonly SandyFamily _family;
        private readonly string _key;
        private readonly string _superCol;

        internal SubColumnGetSelector(SandyClient client, SandyFamily family, string key, string superCol)
        {
            _client = client;
            _family = family;
            _key = key;
            _superCol = superCol;
        }

        public IDictionary<string, string> AllColumns
        {
            get
            {
                // throw new NotImplementedException("request 2: get(cf={0}, key={1}, scol={2}");
                return GetQuery.PerformSuper(_client, _family, _key, _superCol);
            }
        }

        public string this[string column]
        {
            get
            {
                // throw new NotImplementedException("request 3: get(cf={0}, key={1}, scol={2}, col={3})");
                return GetQuery.Perform(_client, _family, _key, _superCol, column);
            }
        }

        public IDictionary<string, string> this[IEnumerable<string> cols]
        {
            get
            {
                // throw new NotImplementedException("request 10: get_slice(cf={0}, key={1}, scol={2}, cols={3}");
                return GetSliceQuery.Perform(_client, _family, _key, _superCol, cols);
            }
        }

        public IDictionary<string, string> this[params string[] cols]
        {
            get
            {
                // Request 11
                return this[(IEnumerable<string>) cols];
            }
        }

        public IDictionary<string, string> this[Range cols]
        {
            get
            {
                // throw new NotImplementedException("request 12: get_slice(cf={0}, key={1}, scol={2}, colRange={3}");
                return GetSliceQuery.Perform(_client, _family, _key, _superCol, cols);
            }
        }
    }
}